# encoding: utf-8
"""
@Author:      "June"
@CreateTime:  2020/5/29 23:09 
@File:        getParams
@Project:     PyCharm
"""
import frida

jscode = """
rpc.exports = {
    getauthorization: function() {
        send('start hook!')
        Java.perform (
            function(){
                var dp = Java.use("com.tianyancha.skyeye.utils.dp");
                var authorization = dp.I();
                send(authorization);
            }
        )
        //return authorization;
    }
}
"""


def on_message(message, data):
    if message['type'] == 'send':
        print("[*] {0}".format(message['payload']))
    else:
        print(message)

process = frida.get_usb_device().attach("com.tianyancha.skyeye")
script = process.create_script(jscode)
script.on('message', on_message)
script.load()

authorization = script.exports.getauthorization()
print(authorization)